package com.nbrc.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * Menu entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "menu", catalog = "nbrcactiviti")
public class Menu implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 736159914377907518L;
	private String id;
	private String name;
	private Set<RolePriv> rolePrivs = new HashSet<RolePriv>(0);
	private Set<Role> roles = new HashSet<Role>(0);

	// Constructors

	/** default constructor */
	public Menu() {
	}

	/** minimal constructor */
	public Menu(String id) {
		this.id = id;
	}

	/** full constructor */
	public Menu(String id, String name, Set<RolePriv> rolePrivs, Set<Role> roles) {
		this.id = id;
		this.name = name;
		this.rolePrivs = rolePrivs;
		this.roles = roles;
	}

	// Property accessors
	@Id
	@Column(name="id",nullable = false,length=40)
	@GeneratedValue(generator="system-uuid")
	@GenericGenerator(name="system-uuid",strategy="org.hibernate.id.UUIDGenerator")
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "name")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "menus")
	@OrderBy("id asc")
	public Set<RolePriv> getRolePrivs() {
		return this.rolePrivs;
	}

	public void setRolePrivs(Set<RolePriv> rolePrivs) {
		this.rolePrivs = rolePrivs;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "menus")
	public Set<Role> getRoles() {
		return this.roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

}